package cn.com.miao.lynx.plugin.push.aop.holder;

import org.springframework.util.Assert;

/**
 * MessagePushContextHolder
 *
 * @title: MessagePushContextHolder
 * @description:
 * @author: dengmiao
 * @create: 2020-01-14 14:13
 **/
public class MessagePushContextHolder {

    /**
     * current thread data source pool name
     */
    private static ThreadLocal<String> MESSAGE_PUSH_CLIENT_NAME = new ThreadLocal<>();

    /**
     * setting current thread pool name
     * @param dataSourcePoolName datasource pool name
     */
    public static void set(String dataSourcePoolName) {
        Assert.notNull(dataSourcePoolName, "DataSource pool name is required.");
        MESSAGE_PUSH_CLIENT_NAME.set(dataSourcePoolName);
    }

    /**
     * get current thread pool name
     * @return data source pool name
     */
    public static String get() {
        return MESSAGE_PUSH_CLIENT_NAME.get();
    }

    /**
     * remove current thread pool name
     */
    public static void remove() {
        MESSAGE_PUSH_CLIENT_NAME.remove();
    }
}
